
from time import sleep

from pages.base_page import BasePage
from selenium.webdriver.common.by import By


class LoginPage(BasePage):
    url = "/crm"
    username_locator = (By.NAME, 'name')
    password_locator = (By.NAME, 'password')
    submit_locator = (By.NAME, 'submit')

    # driver = chrome()
    # driver.get("PROTOCOL://HOST:PORT")
    # cookies = {"name": "ECSCP_ID", "value": "9ea70ee3e39d5e203ffcade12830467bcfe420d0"}
    # driver.add_cookie(cookies)
    # driver.get(r"http://192.168.1.3:8081/upload/admin/index.php")
    # sleep(2)
    #操作
#输入用户名
    def input_username(self, username):
        self.find_element(self.username_locator).send_keys(username)

    def input_password(self, password):
        # self.find_element(*self.password_locator).send_keys(password)
        self.find_element(self.password_locator).send_keys(password)

    def click_login(self):
        self.find_element(self.submit_locator).click()

    def login(self, username, password):
        self.input_username(username)
        self.input_password(password)
        self.click_login()
